<?php

	define('ROOT', '/');
	define('SIDOR', 'sidor/');
	define('LIB', 'lib/');

	$raw_uri = explode('?', rawurldecode($_SERVER['REQUEST_URI']));
	$raw_uri = array_shift($raw_uri);
	$uri = explode('/', substr($raw_uri, strlen(ROOT)));
	
	//Fulfix som förhindar lite errors, du kan strunta i dessa rader
	for($i=0; $i<10; $i++){
		if(empty($uri[$i])){
			$uri[$i] = '';
		}
	}

	function sO($string, $skip_stipslashes = false){ 
		return @htmlentities( $skip_stipslashes?$string:stripslashes($string), ENT_QUOTES, 'UTF-8');
	}

	class URL {
		private static $default_file;
		private static $url = array();
		public static function setDefault($file){
			self::$default_file = $file;
		}
		public static function addURL($url_parts, $file){
			self::$url[] = array('parts' => explode('/', $url_parts), 'file' => $file);
		}
		public static function catchURL($uri){
			$found = false;
			foreach(self::$url as $url_parts){
				foreach($url_parts['parts'] as $url_i => $url_part){
					if(empty($uri[$url_i]) || $uri[$url_i] != $url_part){
						continue 2;
					}
				}
				//Yay!
				$found = true;
				require_once(SIDOR . $url_parts['file']);
				break;
			}
			if(!$found){
				require_once(SIDOR . self::$default_file);
			}
		}
	}


	URL::setDefault('start/start.php');

	URL::addURL('blogg', 						'blogg.php' );
	URL::addURL('kontakt',						'kontakt.php' );
	URL::addURL('webshop', 						'webshop.php');
	
	URL::addURL('omoss/foretaget',				'omoss/foretaget.php');
	URL::addURL('omoss/jennie',					'omoss/jennie.php');
	URL::addURL('omoss/emmily',					'omoss/emmily.php');
	URL::addURL('omoss/varahundar',				'omoss/varahundar.php');
	URL::addURL('omoss/filosofi',				'omoss/filosofi.php');

	URL::addURL('kurser/valp',					'kurser/valp.php');
	URL::addURL('kurser/unghund',				'kurser/unghund.php');
	URL::addURL('kurser/rally',					'kurser/rally.php');


	URL::addURL('doggywalking/hur',				'dw/hur.php');
	URL::addURL('doggywalking/fos',				'dw/fos.php');
	URL::addURL('doggywalking/priser',			'dw/priser.php');
	URL::addURL('doggywalking/intresseanmalan',	'dw/intresseanmalan.php');
	URL::addURL('doggywalking/bilder',			'dw/bilder.php');



?>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Klicka Hundcenter</title>
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<meta name="robots" content="" />
		<link rel="shortcut icon" href="<?php echo ROOT; ?>favicon.ico" type="image/x-icon" />
		<link rel="stylesheet" href="<?php echo ROOT; ?>css/default.css" />
	</head>
	<body>
		<div id="Container">
			<div id="Header"></div>
			<div id="Title" style="top: 8px; font-size: 10px; line-height: 19px;">
				<ul id="menu">
				    <li><a href="<?php echo ROOT; ?>start">Hem</a></li>
				    <li><a href="#">Om oss</a>
				        <ul>
				            <li><a href="<?php echo ROOT; ?>omoss/foretaget">Företaget</a></li>
				            <li><a href="<?php echo ROOT; ?>omoss/jennie">Jennie</a></li>
				            <li><a href="<?php echo ROOT; ?>omoss/emmily">Emmily</a></li>
				            <li><a href="<?php echo ROOT; ?>omoss/varahundar">Våra hundar</a></li>
				            <li><a href="<?php echo ROOT; ?>omoss/filosofi">Filosofi</a></li>
				        </ul>
				    </li>
				    <li><a href="#">Doggywalking</a>
				        <ul>
				            <li><a href="<?php echo ROOT; ?>doggywalking/hur">Hur det går till</a></li>
				            <li><a href="<?php echo ROOT; ?>doggywalking/fos">Frågor & svar</a></li>
				            <li><a href="<?php echo ROOT; ?>doggywalking/priser">Priser</a></li>
				            <li><a href="<?php echo ROOT; ?>doggywalking/intresseanmalan">Intresseanmälan</a></li>
				            <li><a href="<?php echo ROOT; ?>doggywalking/bilder">Bilder</a></li>
				        </ul>
				    </li>
				    <li><a href="#">Dagmatte</a>
				        <ul>
				            <li><a href="<?php echo ROOT; ?>dw/hur">Hur det går till</a></li>
				            <li><a href="<?php echo ROOT; ?>dw/fos">Frågor & svar</a></li>
				            <li><a href="<?php echo ROOT; ?>dw/priser">Priser</a></li>
				            <li><a href="<?php echo ROOT; ?>dw/intresseanmalan">Intresseanmälan</a></li>
				            <li><a href="<?php echo ROOT; ?>dw/bilder">Bilder</a></li>
				        </ul>
				    </li>
				        <li><a href="#">Kurser</a>
				        <ul>
				            <li><a href="<?php echo ROOT; ?>kurser/valp">Valpkurs</a></li>
				            <li><a href="<?php echo ROOT; ?>kurser/unghund">Unghundskurs</a></li>
				            <li><a href="<?php echo ROOT; ?>kurser/rally">Rallylydnadskurs</a></li>
				        </ul>
				    </li>

				    <li><a href="<?php echo ROOT; ?>webshop">Webshop</a></li>
					<li><a href="<?php echo ROOT; ?>kontakt">Kontakt</a></li>
				</ul>		
			</div>
			<div id="Content">
				<div class="scroll-content">
<?php
				URL::catchURL($uri);
?>
				</div>
				<div style="clear:both"></div>
			</div>
			<div id="Footer">
				<div></div>
				<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
				<script src="<?php echo ROOT; ?>js/main.js"></script>
			</div>
		</div>
	</body>
</html>